<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" 
CodeFile="cmi-main.aspx.cs" Inherits="cmi_cmi_main" 
MaintainScrollPositionOnPostback="true" Async="true" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script src="/includes/jtip.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cpBody" runat="Server">
    <div id="divContent">
        <div>
            <div class="body">
                <div class="top">
                </div>
                <div class="body">
                    <div class="padding_lr15px">
                        <!--Column Content | Start-->
                        <div class="col_content">
                            <div class="top">
                            </div>
                            <div class="body">
                                <div class="padding_lr30px">
                                    <h3>
                                        <%=GetGlobalResourceObject("Menu", "OrderCompulsory")%></h3>
                                    <div class="seperator_15px">
                                    </div>
                                    <div id="CarForm">
                                        <asp:Label ID="lblMessage" runat="server"></asp:Label>
                                        <asp:ValidationSummary ID="vsCarProfile" runat="server" ValidationGroup="carprofile"
                                            ShowSummary="True" HeaderText="<%$ Resources:Menu,RequiredValidation%>" CssClass="errorSummary" />
                                        <div class="form_col_1 left">
                                            <asp:Label ID="lblVehicleType" runat="server" Text="<%$ Resources:CarInsurance,CarType%>" />
                                        </div>
                                        <div class="form_col_2 left">
                                            <asp:RadioButtonList runat="server" ID="rdlVehicleType" RepeatDirection="Vertical"
                                                onclick="GetCTPL();">
                                                <asp:ListItem Text="<%$Resources:CarInsurance,VehicleType1%>" Value="1"></asp:ListItem>
                                                <asp:ListItem Text="<%$Resources:CarInsurance,VehicleType2%>" Value="2"></asp:ListItem>
                                                <asp:ListItem Text="<%$Resources:CarInsurance,VehicleType3%>" Value="3"></asp:ListItem>
                                            </asp:RadioButtonList>
                                            <asp:RequiredFieldValidator ID="rfvVehicleType" ControlToValidate="rdlVehicleType"
                                                CssClass="validationErrorControl" runat="server" ValidationGroup="carprofile"
                                                Text="" ErrorMessage=""></asp:RequiredFieldValidator>
                                        </div>
                                        <div class="seperator_form">
                                        </div>
                                        <div class="form_col_1 left">
                                            <asp:Label ID="lblInsurer" runat="server" Text="<%$ Resources:CarInsurance,Insurer%>" />
                                        </div>
                                        <div class="form_col_2 left">
                                            <ul id="rdlInsurer" style="list-style-type:none; line-height:30px">
                                            <li><asp:RadioButton runat="server" ID="rdlInsurer1" GroupName="CTPLInsurer" onclick="GetCTPL();" Text="<%$Resources:CarInsurance,CTPLCompany1%>" /></li>
                                            <li><asp:RadioButton runat="server" ID="rdlInsurer2" GroupName="CTPLInsurer" onclick="GetCTPL();" Text="<%$Resources:CarInsurance,CTPLCompany2%>" /></li>
                                            </ul>
                                            <asp:CustomValidator id="ctvInsurer" runat="server" ValidationGroup="carprofile" Display="Dynamic" ErrorMessage="" ClientValidationFunction="ctvInsurer_ClientValidate" OnServerValidate="ctvInsurer_ServerValidate"></asp:CustomValidator>
                                        </div>
                                        <div class="seperator_form">
                                        </div>
                                        <div>
                                            <table style="border-collapse: collapse;width:100%" cellpadding="2" cellspacing="1">
                                                <tr>
                                                    <td>
                                                        <b>
                                                            <%=GetGlobalResourceObject("ResultPage", "CTPL")%></b>
                                                    </td>
                                                    <td>
                                                        <b>
                                                            <%=GetGlobalResourceObject("CarInsurance", "Discount")%></b>
                                                    </td>
                                                    <td><b>
                                                            <%=GetGlobalResourceObject("CarInsurance", "Total")%></b>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label runat="server" ID="lblSumCTPL"></asp:Label><asp:HiddenField runat="server" ID="hidSumCTPL" />
                                                    </td>
                                                    <td style="color:Red">
                                                        <asp:Label runat="server" ID="lblSumDiscount"></asp:Label><asp:HiddenField runat="server" ID="hidSumDiscount" />
                                                    </td>
                                                    <td><strong><asp:Label runat="server" ID="lblTotal"></asp:Label><asp:HiddenField runat="server" ID="hidTotal" /></strong>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                        <div class="seperator_15px">
                                        </div>
                                        <div>
                                            <asp:Button ID="btnNext" onmousedown="this.className = 'button_next_mousedown';"
                                                onmouseup="this.className = 'button_next';" onmouseout="this.className = 'button_next';"
                                                CssClass="button_next" OnClientClick="LoadValidationErrorCss();if (Page_ClientValidate('carprofile')){this.removeAttribute('onmouseout');this.removeAttribute('onmouseup');this.className = 'button_processing';}"
                                                runat="server" ValidationGroup="carprofile" ToolTip="Next" CausesValidation="true"
                                                OnClick="btnNext_Click" />
                                        </div>
                                        <br />
                                        <br />
                                        <div style="width: 100%; text-align: center">
                                            <table style="border-collapse: collapse;" cellpadding="2" cellspacing="1">
                                                <tr>
                                                    <td bgcolor="#FF9900" style="border: solid 1px #7889A7; color: white">
                                                        <b>
                                                            <%=GetGlobalResourceObject("CarInsurance", "OrderOnlineWithPayment")%></b>
                                                    </td>
                                                    <td bgcolor="#FF9900" style="border: solid 1px #7889A7; color: white">
                                                        <b>
                                                            <%=GetGlobalResourceObject("CarInsurance", "ActPolicyViaEmail")%></b>
                                                    </td>
                                                    <td bgcolor="#FF9900" style="border: solid 1px #7889A7; color: white">
                                                        <b>
                                                            <%=GetGlobalResourceObject("CarInsurance", "FreeDeliveryByThaiPost")%></b>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "MonFri1")%>
                                                    </td>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "SameDay")%>
                                                    </td>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "SameDay")%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "MonFri2")%>
                                                    </td>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "SameDay")%>
                                                    </td>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "NexrDay")%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "MonFri3")%>
                                                    </td>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "NexrDay")%>
                                                    </td>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "NexrDay")%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "Weekend")%>
                                                    </td>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "Monday")%>
                                                    </td>
                                                    <td style="border: solid 1px #7889A7; text-align: left">
                                                        <%=GetGlobalResourceObject("CarInsurance", "Monday")%>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                        <!--Form | End-->
                                    </div>
                                </div>
                            </div>
                            <div class="bottom">
                            </div>
                        </div>
                        <!--Column Content | End-->
                        <!--Column Right | Start-->
                        <div>
                            <div id="Hotline" style="text-align: center; padding-left: 15px;">
                                <asp:Image ID="imgBanner" runat="server" ImageUrl="<%$Resources:ImageResource,PaymentStepUrl%>"
                                    AlternateText="Payment" />
                            </div>
                        </div>
                        <!--Column Right | End-->
                    </div>
                </div>
                <div class="bottom">
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">

        function GetCTPL() {
            var selCar = $('#<%= rdlVehicleType.ClientID %> input:checked').val();
            if (selCar == "1") {
                document.getElementById('<%=lblSumCTPL.ClientID%>').innerHTML = "645.21";
                document.getElementById('<%=hidSumCTPL.ClientID%>').value = "645.21";

                document.getElementById('<%=lblSumDiscount.ClientID%>').innerHTML = "77.43";
                document.getElementById('<%=hidSumDiscount.ClientID%>').value = "77.43";

                document.getElementById('<%=lblTotal.ClientID%>').innerHTML = "567.78";
                document.getElementById('<%=hidTotal.ClientID%>').value = "567.78";
            }
            else if (selCar == "2") {
                document.getElementById('<%=lblSumCTPL.ClientID%>').innerHTML = "967.28";
                document.getElementById('<%=hidSumCTPL.ClientID%>').value = "967.28";

                document.getElementById('<%=lblSumDiscount.ClientID%>').innerHTML = "116.07";
                document.getElementById('<%=hidSumDiscount.ClientID%>').value = "116.07";

                document.getElementById('<%=lblTotal.ClientID%>').innerHTML = "851.20";
                document.getElementById('<%=hidTotal.ClientID%>').value = "851.20";
            }
            else if (selCar == "3") {
                document.getElementById('<%=lblSumCTPL.ClientID%>').innerHTML = "1182.35";
                document.getElementById('<%=hidSumCTPL.ClientID%>').value = "1182.35";

                document.getElementById('<%=lblSumDiscount.ClientID%>').innerHTML = "141.88";
                document.getElementById('<%=hidSumDiscount.ClientID%>').value = "141.88";

                document.getElementById('<%=lblTotal.ClientID%>').innerHTML = "1040.47";
                document.getElementById('<%=hidTotal.ClientID%>').value = "1040.47";
            }
        }

        function ctvInsurer_ClientValidate(source, args) {
            if (document.getElementById("<%= rdlInsurer1.ClientID %>").checked || document.getElementById("<%= rdlInsurer2.ClientID %>").checked) {
                document.getElementById("rdlInsurer").className = "";
                args.IsValid = true;
            }
            else {
                document.getElementById("rdlInsurer").className = "validationError";
                args.IsValid = false;
                
            }
        }
        
    </script>

</asp:Content>
